package com.axsoft.jobimp.tests;

import junit.framework.TestCase;

import com.axsoft.jobimp.types.BLK;
import com.axsoft.jobimp.types.LongWord;
import com.axsoft.jobimp.types.Word;
import com.axsoft.jobimp.types.sTLD;
import com.axsoft.jobimp.types.wTLD;


public class TLDTest extends TestCase {
	
	public void testRawSTLD() {
		final byte[] constBytes = { 0x02 };
		final sTLD sTld = new sTLD((short)0x00, constBytes);
		
		final byte[] bytesExpected = {	0x00, 0x00,	// Type
										0x00, 0x01,	// Length
										0x02		// Data
									 }; 
		final byte[] bytes = sTld.toBLK().getData();
		
		assertEquals(1, sTld.getLength());
		assertTrue(OTestUtils.byteArraysEquals(bytes, bytesExpected));
	}
	
	
	public void testObjSTLD() {
		final byte[] constBytes = { 0x02 };
		final sTLD sTld = new sTLD(new Word((short)0x00), 
				new BLK(constBytes));
		
		final byte[] bytesExpected = {	0x00, 0x00,	// Type
										0x00, 0x01,	// Length
										0x02		// Data
									 }; 
		
		final byte[] bytes = sTld.toBLK().getData();
		
		assertEquals(1, sTld.getLength());
		assertTrue(OTestUtils.byteArraysEquals(bytes, bytesExpected));
	}
	
	public void testRawWTLD() {
		final byte[] constBytes = { 0x02 };
		final wTLD wTld = new wTLD(0x00, constBytes);
		
		final byte[] bytesExpected = {	0x00, 0x00, 0x00, 0x00,	// Type
										0x00, 0x00, 0x00, 0x01,	// Length
										0x02					// Data
									 }; 
		
		final byte[] bytes = wTld.toBLK().getData();
		
		assertEquals(1, wTld.getLength());
		assertTrue(OTestUtils.byteArraysEquals(bytes, bytesExpected));
	}
	
	public void testObjWTLD() {
		final byte[] constBytes = { 0x02 };
		final wTLD wTld = new wTLD(new LongWord(0x00), new BLK(constBytes));
		
		final byte[] bytesExpected = {	0x00, 0x00, 0x00, 0x00,	// Type
										0x00, 0x00, 0x00, 0x01,	// Length
										0x02					// Data
									 };
		
		final byte[] bytes = wTld.toBLK().getData();
		
		assertEquals(1, wTld.getLength());
		assertTrue(OTestUtils.byteArraysEquals(bytes, bytesExpected));
	}
	
}
